package rpt.yto.util;

import java.util.Comparator;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class ConvertFunc {
	
	private static final ConvertFunc convert = new ConvertFunc();

	private ConvertFunc() {
		
	}
	
	public static final ConvertFunc getInstance() {
		return convert;
	}
	
	/**
	 * 功能 : 将字符串数组转换为字符串。
	 * 
	 * Author : river 
	 * 
	 * Create : 2012-08-20
	 * 
	 * @param strArray
	 * @return
	 * @throws Exception
	 */
	public final String change(String[] strArray) throws Exception {
		return change(strArray , null , null , ",");
	}
	
	/**
	 * 功能 : 按照分割类型将字符串数组转换为字符串。
	 * 
	 * 
	 * Author : river 
	 * 
	 * Create : 2012-08-20
	 * 
	 * @param strArray
	 * @return
	 * @throws Exception
	 */
	public final String change(String[] strArray , String beforeChar, String afterChar,  String splitType) throws Exception {
		
		String newStr = "";
		for(String str : strArray) {
			if(str == null || "".equals(str)) {
				continue;
			}
			
			newStr += change(beforeChar) + str + change(afterChar) + change(splitType);
		}
		
		if(newStr.length() > 0)
			newStr = newStr.substring(0 , newStr.length() - 1);
		
		return newStr;
	}
	
	public final String change(Object val) throws Exception {
		
		if(val == null)
			return "";
		
		return String.valueOf(val);
		
	}
	
}
